From 80cbd169b19db54e13248e7ff9c61d93255fe5f5 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Wed, 10 Aug 2005 21:14:38 +0000 Subject: [PATCH] yet more of Lufthansa stuff, embedable Prefix-restricted page list, as well a separate SpecialPage --- includes/SpecialPage.php | 1 + includes/SpecialPrefixindex.php | 134 ++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 includes/SpecialPrefixindex.php diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 3135b0317a..2d03f421ca 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -53,6 +53,7 @@ $wgSpecialPages = array( 'Ancientpages' => new SpecialPage( 'Ancientpages' ), 'Deadendpages' => new SpecialPage( 'Deadendpages' ), 'Allpages' => new IncludableSpecialPage( 'Allpages' ), + 'Prefixindex' => new IncludableSpecialPage( 'Prefixindex' ) , 'Ipblocklist' => new SpecialPage( 'Ipblocklist' ), 'Specialpages' => new UnlistedSpecialPage( 'Specialpages' ), 'Contributions' => new UnlistedSpecialPage( 'Contributions' ), diff --git a/includes/SpecialPrefixindex.php b/includes/SpecialPrefixindex.php new file mode 100644 index 0000000000..29e5637a94 --- /dev/null +++ b/includes/SpecialPrefixindex.php @@ -0,0 +1,134 @@ +getVal( 'from' ); + $namespace = $wgRequest->getInt( 'namespace' ); + + $namespaces = $wgContLang->getNamespaces(); + + $indexPage = new SpecialPrefixIndex(); + + if( !in_array($namespace, array_keys($namespaces)) ) + $namespace = 0; + + $wgOut->setPagetitle( $namespace > 0 ? + wfMsg( 'allinnamespace', $namespaces[$namespace] ) : + wfMsg( 'allarticles' ) + ); + + + if ( isset($par) ) { + $indexPage->showChunk( $namespace, $par, $specialPage->including() ); + } elseif ( isset($from) ) { + $indexPage->showChunk( $namespace, $from, $specialPage->including() ); + } else { + $wgOut->addHtml($indexPage->namespaceForm ( $namespace, $from )); + } +} + +class SpecialPrefixindex extends SpecialAllpages { + var $maxPerPage=960; + var $topLevelMax=50; + var $name='Prefixindex'; + +/** + * @param integer $namespace (Default NS_MAIN) + * @param string $from list all pages from this name (default FALSE) + */ +function showChunk( $namespace = NS_MAIN, $from, $including = false ) { + global $wgOut, $wgUser, $wgContLang; + + $fname = 'indexShowChunk'; + + $sk = $wgUser->getSkin(); + + $fromTitle = Title::newFromURL( $from ); + if ($namespace == NS_MAIN and $fromTitle) { + $namespace = $fromTitle->getNamespace(); + } + + $fromKey = is_null( $fromTitle ) ? '' : $fromTitle->getDBkey(); + + $dbr =& wfGetDB( DB_SLAVE ); + + $res = $dbr->select( 'page', + array( 'page_namespace', 'page_title', 'page_is_redirect' ), + array( + 'page_namespace' => $namespace, + 'page_title LIKE \'' . $dbr->escapeLike( $fromKey ) .'%\'' + ), + $fname, + array( + 'ORDER BY' => 'page_title', + 'LIMIT' => $this->maxPerPage + 1, + 'USE INDEX' => 'name_title', + ) + ); + + ### FIXME: side link to previous + + $n = 0; + $out = ''; + + $namespaces = $wgContLang->getFormattedNamespaces(); + while( ($n < $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { + $t = Title::makeTitle( $s->page_namespace, $s->page_title ); + if( $t ) { + $link = ($s->page_is_redirect ? '
' : '' ) . + $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . + ($s->page_is_redirect ? '
' : '' ); + } else { + $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; + } + if( $n % 3 == 0 ) { + $out .= ''; + } + $out .= ""; + $n++; + if( $n % 3 == 0 ) { + $out .= ''; + } + } + if( ($n % 3) != 0 ) { + $out .= ''; + } + $out .= '
$link
'; + + if ( $including ) { + $out2 = ''; + } else { + $nsForm = $this->namespaceForm ( $namespace, $from ); + $out2 = ''; + $out2 .= '
' . $nsForm; + $out2 .= '' . + $sk->makeKnownLink( $wgContLang->specialPage( $this->name ), + wfMsg ( 'allpages' ) ); + if ( ($n == $this->maxPerPage) && ($s = $dbr->fetchObject( $res )) ) { + $namespaceparam = $namespace ? "&namespace=$namespace" : ""; + $out2 .= " | " . $sk->makeKnownLink( + $wgContLang->specialPage( $this->name ), + wfMsg ( 'nextpage', $s->page_title ), + "from=" . wfUrlEncode ( $s->page_title ) . $namespaceparam ); + } + $out2 .= "

"; + } + + $wgOut->addHtml( $out2 . $out ); +} +} + +?> -- 2.20.1